package com.dongwq

class PageShowTagLib {

	static namespace = "ps";

	def readMore ={attrs, body->
		String bodyText=body()
		int id= Math.abs(new Random().nextInt(9999))
		String script="""
		  <style>.myClass{height:30px;overflow:hidden;width:500px;margin:auto;}</style>
		  <div style="width:500px;margin:auto">
		  <br/><br/>
		  <p class="myClass" id=${id+1}>${bodyText}</p>
		  <p style="float:right;"><a href="javascript:void(0)" style="color:blue;"id=${id}>Read More/Less...</a></p>
		  </div>
		  <br/><br/>
		  <script type="text/javascript">
		   jQuery('a#${id}').click(function(){
			   jQuery('p#${id+1}').toggleClass("myClass");
		   })

		  </script>
		"""
		out << script
	}
}
